home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _1ADDEEAAE3B44F9C9C0D11B0ACB631CD < prev    next >
Encoding:
Text File  |  2004-01-06  |  7.4 KB  |  203 lines

  1. --------------------------------------------------
  2. --   Created By: Petar
  3. --   Description: Rear Idle Behaviour
  4. --------------------------
  5.  
  6.  
  7. AIBehaviour.RearIdle = {
  8.     Name = "RearIdle",
  9.  
  10.  
  11.  
  12.  
  13.     ---------------------------------------------        
  14.     OnPlayerSeen = function( self, entity, fDistance )
  15.         -- called when the enemy sees a living player
  16.         if (fDistance < 15) then
  17.             AI:Signal(0,1,"ON_ENEMY_TOOCLOSE",entity.id);
  18.             entity:SelectPipe(0,"rear_target2close");
  19.         else
  20.             AI:Signal(0,1,"ON_ENEMY_TARGET",entity.id);
  21.             entity:SelectPipe(0,"rear_scramble");
  22.         end
  23.  
  24.         if (entity.RunToTrigger == nil) then
  25.             entity:RunToAlarm();
  26.         end
  27.         
  28.         if (AI:GetGroupCount(entity.id) > 1) then
  29.             AI:Signal(SIGNALFILTER_SUPERGROUP, 1, "wakeup",entity.id);
  30.             AI:Signal(SIGNALID_READIBILITY, AIREADIBILITY_SEEN, "FIRST_HOSTILE_CONTACT_GROUP",entity.id);    
  31.             AI:Signal(SIGNALFILTER_SUPERGROUP, 1, "HEADS_UP_GUYS",entity.id);
  32.             entity:InsertSubpipe(0,"DropBeaconAt"); -- in PipeManagerShared.lua
  33.         else
  34.             AI:Signal(SIGNALID_READIBILITY, AIREADIBILITY_SEEN, "FIRST_HOSTILE_CONTACT",entity.id);
  35.         end
  36.         
  37.     end,
  38.  
  39.     ---------------------------------------------
  40.     OnSomethingSeen = function( self, entity )
  41.  
  42.         -- DO NOT TOUCH THIS READIBILITY SIGNAL    ---------------------------
  43.         if (AI:GetGroupCount(entity.id) > 1) then
  44.             AI:Signal(SIGNALID_READIBILITY, AIREADIBILITY_INTERESTED, "IDLE_TO_INTERESTED_GROUP",entity.id);
  45.         else
  46.             AI:Signal(SIGNALID_READIBILITY, AIREADIBILITY_INTERESTED, "IDLE_TO_INTERESTED",entity.id);
  47.         end
  48.         -------------------------------------------------------------------
  49.         entity:MakeAlerted();
  50.          entity:SelectPipe(0,"rear_interested"); 
  51.         entity:InsertSubpipe(0,"get_curious"); 
  52.          entity:InsertSubpipe(0,"setup_combat"); 
  53.          entity:InsertSubpipe(0,"DropBeaconAt"); 
  54.          entity:InsertSubpipe(0,"DRAW_GUN"); 
  55.     end,
  56.  
  57.     ---------------------------------------------
  58.     OnInterestingSoundHeard = function( self, entity )
  59.  
  60.         -- DO NOT TOUCH THIS READIBILITY SIGNAL    ---------------------------
  61.         if (AI:GetGroupCount(entity.id) > 1) then
  62.             AI:Signal(SIGNALID_READIBILITY, AIREADIBILITY_NORMAL, "IDLE_TO_INTERESTED_GROUP",entity.id);
  63.         else
  64.             AI:Signal(SIGNALID_READIBILITY, AIREADIBILITY_NORMAL, "IDLE_TO_INTERESTED",entity.id);
  65.         end
  66.         -------------------------------------------------------------------
  67.          entity:SelectPipe(0,"rear_interested"); 
  68.          entity:InsertSubpipe(0,"setup_combat"); 
  69.          entity:InsertSubpipe(0,"DropBeaconAt"); 
  70.          entity:InsertSubpipe(0,"DRAW_GUN"); 
  71.     end,
  72.     ---------------------------------------------
  73.     OnThreateningSoundHeard = function( self, entity )
  74.         entity:MakeAlerted();
  75.         entity:SelectPipe(0,"rear_interested"); 
  76.         entity:InsertSubpipe(0,"shoot_cover"); 
  77.          entity:InsertSubpipe(0,"setup_combat"); 
  78.         entity:InsertSubpipe(0,"DropBeaconAt"); 
  79.          entity:InsertSubpipe(0,"DRAW_GUN"); 
  80.         entity:Blind_RunToAlarm();
  81.     end,
  82.     ---------------------------------------------
  83.     OnBulletRain = function ( self, entity, sender)    
  84.         -- called when detect weapon fire around AI
  85.     
  86.         AI:Signal(SIGNALFILTER_GROUPONLY, 1, "INCOMING_FIRE",entity.id);
  87.         
  88.         entity:MakeAlerted();
  89.         entity:SelectPipe(0,"randomhide");
  90.         entity:InsertSubpipe(0,"DRAW_GUN");
  91.     end,
  92.     ---------------------------------------------
  93.     OnReceivingDamage = function ( self, entity, sender)
  94.         -- called when the enemy is damaged
  95.         AI:Signal(SIGNALFILTER_GROUPONLY, 1, "INCOMING_FIRE",entity.id);
  96.  
  97.         -- DO NOT TOUCH THIS READIBILITY SIGNAL    ------------------------
  98.         AI:Signal(SIGNALID_READIBILITY, 1, "GETTING_SHOT_AT",entity.id);
  99.         ----------------------------------------------------------------
  100.  
  101.         entity:MakeAlerted();
  102.         entity:SelectPipe(0,"randomhide");
  103.         entity:InsertSubpipe(0,"DRAW_GUN");
  104.     end,
  105.     --------------------------------------------------
  106.     OnGrenadeSeen = function( self, entity, fDistance )
  107.         -- called when the enemy sees a grenade
  108.         --System:LogToConsole("+++++++++++++++++++++++++++OnGrenadeSeen");
  109.         entity:InsertSubpipe(0,"grenade_run_away");
  110.     end,
  111.     --------------------------------------------------
  112.     -- CUSTOM SIGNALS
  113.     --------------------------------------------------
  114.     DEATH_CONFIRMED = function (self, entity, sender)
  115.         --System:LogToConsole(entity:GetName().." recieved DEATH_CONFIRMED command in CoverAlert");
  116.         entity:SelectPipe(0,"ChooseManner");
  117.     end,
  118.     --------------------------------------------------
  119.     TRY_TO_LOCATE_SOURCE = function (self, entity, sender)
  120.         -- called from "randomhide"
  121.         entity:SelectPipe(0,"rear_lookaround_threatened");
  122.     end,
  123.     ---------------------------------------------
  124.     ChooseManner = function (self, entity, sender)
  125.         --System:LogToConsole("### ChooseManner ###");
  126.         local XRandom = random(1,3);
  127.         if (XRandom == 1) then
  128.             entity:InsertSubpipe(0,"LookForThreat");            
  129.         elseif (XRandom == 2) then
  130.             entity:InsertSubpipe(0,"RandomSearch");            
  131.         elseif (XRandom == 3) then
  132.             entity:InsertSubpipe(0,"ApproachDeadBeacon");
  133.         end
  134.     end,
  135.     ---------------------------------------------
  136.     OnGroupMemberDied = function( self, entity, sender)
  137.         -- called when a member of the group dies
  138.         --System:LogToConsole(entity:GetName().." recieved OnGroupMemberDied signal in RearIdle");
  139.  
  140.         entity:MakeAlerted();
  141.         
  142.         if (sender.Properties.groupid == entity.Properties.groupid) then
  143.              if (entity ~= sender) then
  144.                  entity:SelectPipe(0,"TeamMemberDiedLook");
  145.              end
  146.         else
  147.              entity:SelectPipe(0,"randomhide");
  148.         end
  149.     end,
  150.     --------------------------------------------------
  151.     OnGroupMemberDiedNearest = function ( self, entity, sender)
  152.         --System:LogToConsole(entity:GetName().." recieved OnGroupMemberDiedNearest signal in CoverIdle");
  153.  
  154.         entity:MakeAlerted();
  155.  
  156.         -- DO NOT TOUCH THIS READIBILITY SIGNAL    ---------------------------
  157.         AI:Signal(SIGNALID_READIBILITY, 1, "FRIEND_DEATH",entity.id);
  158.         -------------------------------------------------------------------
  159.         
  160.         -- bounce the dead friend notification to the group (you are going to investigate it)
  161.         AI:Signal(SIGNALFILTER_SPECIESONLY, 1, "OnGroupMemberDied",entity.id);
  162.  
  163.         -- investigate corpse
  164.         entity:SelectPipe(0,"RecogCorpse",sender.id);
  165.     end,
  166.     --------------------------------------------------
  167.     ----------------- GROUP SIGNALS ------------------
  168.     --------------------------------------------------
  169.     HEADS_UP_GUYS = function (self, entity, sender)
  170.         if (entity ~= sender) then
  171.             entity:MakeAlerted();
  172.             entity:SelectPipe(0,"rear_headup");
  173.             if (entity.AI_GunOut==nil) then    
  174.                 entity:InsertSubpipe(0,"DRAW_GUN");
  175.             end
  176.         end
  177.         entity.RunToTrigger = 1;
  178.     end,
  179.     ---------------------------------------------
  180.     INCOMING_FIRE = function (self, entity, sender)
  181.         if (entity ~= sender) then
  182.             entity:SelectPipe(0,"randomhide");
  183.             if (entity.AI_GunOut==nil) then 
  184.                 entity:InsertSubpipe(0,"DRAW_GUN");    
  185.             end
  186.  
  187.         end
  188.     end,
  189.     ---------------------------------------------
  190.     OnCoverRequested = function ( self, entity, sender)
  191.         -- called when cover is requested
  192.     end,
  193.     ------------------------------------------------------------------------
  194.     ------------------------------ Animation -------------------------------
  195.     PlayGetDownAnim = function (self, entity, sender)
  196.         entity:StartAnimation(0,"pgetdown",0);
  197.     end,
  198.     ------------------------------------------------------------------------
  199.     PlayGetUpAnim = function (self, entity, sender)
  200.         entity:StartAnimation(0,"pgetup",0);
  201.     end,
  202.     ------------------------------------------------------------------------
  203. }